<?php

namespace app\common\service\order\coupon_order\taobao;

use app\api\controller\Coupon;
use app\common\service\order\coupon_order\Base;
use app\common\service\order\coupon_order\CouponOrderChannelInterface;
use app\model\CouponOrder;

class EleTaobaoBase extends Base implements CouponOrderChannelInterface
{

    public function getSupplierOrderSn()
    {
        return $this->params['biz_order_id'] ?? '';
    }

    public function getAmount()
    {
        $amount = $this->params['full_settle_amount'] ?? 0;
        return yuan2fen($amount);
    }

    public function getOrderAllCommission()
    {
        return $this->params['income'] ?? 0;
    }

    public function getOriginAmount()
    {
        return $this->getPayAmount();
    }

    public function getPayAmount()
    {
        $amount = $this->params['full_settle_amount'] ?? 0;

        return yuan2fen($amount);
    }

    public function getPayStatus()
    {
        return !empty($this->params['pay_time']) ? CouponOrder::C_PAY_STATUS_YES : CouponOrder::C_PAY_STATUS_NO;
    }

    public function getPayTime()
    {
        return $this->params['pay_time'] ?? '';
    }

    public function getStatusDesc()
    {
    }

    public function getType()
    {
        return 2;
    }

    public function getSettleType()
    {
        return SETTLE_TYPE_PROFIT;
    }

    public function getExtData()
    {
        return $this->params;
    }

    public function getOrderCreatedAt()
    {
        return $this->params['tk_create_time'] ?? '';
    }

    public function getTitle()
    {
        return $this->params['title'] ?? '';
    }

    public function getRefundStatus()
    {
        $status = $this->params['order_item_status'] ?? 0;

        if ($status == 5) {
            return CouponOrder::C_REFUND_STATUS_HAVE;
        }

        return CouponOrder::C_REFUND_STATUS_NO;

    }

    public function getSid()
    {
        return $this->params['sid'];
    }

    public function getOutOrderId()
    {
        return $this->getSupplierOrderSn();
    }
}